home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9645 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  40 lines

  1. Newsgroups: comp.lang.c,comp.unix.aix
  2. Path: ritz.mordor.com!news
  3. From: benjamin@ritz.mordor.com (Joseph Thomas)
  4. Subject: Help: write() to a socket hangs unless there's a newline
  5. X-Newsreader: Gnus v5.1
  6. X-Nntp-Posting-User: benjamin
  7. Sender: benjamin@ritz.mordor.com
  8. Organization: none
  9. Message-ID: <5r68cae4wm.fsf@ritz.mordor.com>
  10. X-Nntp-Posting-Host: ritz.mordor.com
  11. Date: Tue, 12 Mar 1996 14:56:41 GMT
  12.  
  13. I realize this is not a direct C question, but it does have to do with
  14. streams, and I tend to think the expertise to answer this is here:
  15.  
  16. I've opened a socket, and connected it to another.  I'm using write() to
  17. send a message through, ex:
  18.  
  19. write(sock_fd, "Hello world", strlen("Hello world"));
  20.  
  21. When I do this, the message gets through to the other socket, but the
  22. write() call hangs in the process that executed it.
  23.  
  24. However, if I send it as: 
  25.  
  26. write(sock_fd, "Hello world\n", strlen("Hello world\n"));
  27.  
  28. It doesn't hang, but I have a newline I don't want at the other end.
  29. In addition, for some reason, between the next write()-->read() that I
  30. try, I read() two null strings before I actually get the next
  31. message (this may be something particular to sockets?)
  32.  
  33. I've tried using fflush(sock_fd), but that causes a broken pipe for
  34. some reason.  Can anyone say what gives here?
  35.  
  36. Please, no advice about not using write()
  37.  
  38. TIA
  39.     -Joe
  40.